<template>
  <div class="app-container" v-loading="loading.getPageList">
    <div>
      <el-button type="primary" size="small" @click="getPageList">刷新</el-button>
    </div>
    <br />

    <el-table :data="tableData" border style="width: 100%" highlight-current-row>
      <el-table-column type="index" label="序号" width="60"> </el-table-column>
      <el-table-column prop="name" label="标题"></el-table-column>
      <el-table-column prop="workflowName" label="流程名称" width="250">
        <template  slot-scope="scope">
          <span>{{scope.row.workflowId.workflowName}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="workflowName" label="处理方式" width="80">
        <template  slot-scope="scope">
          <span>{{scope.row.workStepType==0?'审批':'查看（抄送）'}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="workflowName" label="是否已读" width="80">
        <template  slot-scope="scope">
          <el-link
            :underline="false"
            v-if="scope.row.isRead"
            type="success"
            >已读</el-link
          >
          <el-link
            :underline="false"
            v-else
            type="danger"
            >未读</el-link
          >
        </template>
      </el-table-column>
      <el-table-column
        prop="creationTime"
        :formatter="dateFormat"
        label="创建时间"
        width="160"
      >
      </el-table-column>
      <el-table-column
        prop="modifiedTime"
        :formatter="dateFormat"
        label="更新时间"
        width="160"
      >
      </el-table-column>

      <el-table-column fixed="right" label="操作" width="150">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.workflowStatus != 0"
            @click="$refs.processForm.show(scope.row.id)"
            type="text"
            size="small"
            >{{scope.row.workStepType==0?'办理':'查看'}}</el-button
          >
          <el-button
            @click="$refs.workflowDesignForm.show({id:scope.row.workflowId.id,version:scope.row.workflowId.versionNo,taskId:scope.row.id})"
            type="text"
            size="small"
            >流程图</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <br />
    <el-pagination
      background
      layout="sizes,prev, pager, next"
      :total="page.total"
      :page-size="page.maxResultCount"
      :current-page="page.currentPage"
      @current-change="(current) => paginationChange(null, current)"
      @size-change="(size) => paginationChange(size)"
    >
    </el-pagination>

    <processForm ref="processForm" @ok-click="getPageList"></processForm>
    
    <workflowDesignForm ref="workflowDesignForm"></workflowDesignForm>
  </div>
</template>

<script>
import TableIndex from "@/layout/mixin/TableIndex";
import processForm from "./processForm";
import workflowDesignForm from '@/views/workflows/workflow/viewWorkflowForm.vue'
export default {
  components: { processForm ,workflowDesignForm},
  mixins: [TableIndex],
  data() {
    return {
      moduleName: "workflow",
    };
  },
  mounted() {},
  methods: {
    getPageList() {
      this.loading.getPageList = true;
      this.page.skipCount =
        (this.page.currentPage - 1) * this.page.maxResultCount;
      this.$store
        .dispatch("workflow/getUnHandledWorkTasksOfUser", this.page)
        .then((res) => {
          this.tableData = res.items;
          this.page.total = res.total;
          this.loading.getPageList = false;
        });
    },
  },
};
</script>

<style></style>
